/* Copyright (C) 2007-2008  klevgert  http://code.google.com/p/db4o-netbeans/

This file is part of the db4o-netbeans module suite.

db4o-netbeans is free software; you can redistribute it and/or modify it under
the terms of version 2 of the GNU General Public License as published
by the Free Software Foundation.
 
db4o-netbeans is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */

package com.db4o.nb.wizards;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;

/**
 * Base wizard panel for this module. It contains a collection of useful methods
 * which help controlling the user flow through the wizard.
 *
 * @author Rogue.
 */
public abstract class AbstractWizardPanel implements WizardDescriptor.Panel {
    
    private final Set listeners = new HashSet(1);
    
    /**
     * Get the default help context.
     */
    public HelpCtx getHelp() {
        return HelpCtx.DEFAULT_HELP;
    }
    
    /**
     * Add a change listener for this wizard panel.
     */
    public final void addChangeListener(ChangeListener l) {
        synchronized (listeners) {
            listeners.add(l);
        }
    }
    
    /**
     * Remove a change listener from this wizard panel.
     */
    public final void removeChangeListener(ChangeListener l) {
        synchronized (listeners) {
            listeners.remove(l);
        }
    }
    
    /**
     * Fires a change event.
     */
    protected final void fireChangeEvent() {
        Iterator itr;
        synchronized (listeners) {
            itr = new HashSet(listeners).iterator();
        }
        ChangeEvent ev = new ChangeEvent(this);
        while (itr.hasNext()) {
 //           itr.next().stateChanged(ev);
        }
    }
    
    /**
     * Specifies if the current panel has completed processing or not.
     */
    public abstract boolean isPanelProcessingComplete();
    
    /**
     * Terminate any processing in the panel.
     */
    public abstract void terminateProcessing();
    
}